<?php

namespace IDock\Insurance\ZSIC\Response;

use IDock\Http\Response;
use IDock\Insurance\ZSIC\Response\AllZSICResponse;
use IDock\Printer\VehicleActualValuePrinter;

class VehicleActualValueResponse extends AllZSICResponse
{
    public function printerInit(): Response
    {
        $vehicleActualValuePrinter = new VehicleActualValuePrinter();

        $data = $this->getBody();
        $code = $data['head']['resultCode'] ?? '';
        if($code != '01'){
            $this->setError($data['head']['errorMsg']);
            $this->printer = $vehicleActualValuePrinter;
            return  $this;
        }
        $body = $data['body'] ?? [];
        $result = $body['vehicle'];
        $vehicleActualValuePrinter->actualValue =  $result['actualValue'] ?? '';
        $vehicleActualValuePrinter->actualValueMax = $result['maxValue'] ?? '';
        $vehicleActualValuePrinter->actualValueMin = $result['minValue'] ?? '';
        $this->printer = $vehicleActualValuePrinter;
        return  $this;
    }
}
